<template>
  <div class="home">
    <h3>FLV.js HTTP-FLV直播流</h3>
    <div class="videoBox" v-if="isReloadBox">
      <video autoplay controls width="100%" height="500" id="videoElement" muted></video>
    </div>
  </div>
</template>

<script>
import flvjs from 'flv.js'

export default {
  name: 'Home',
  data(){
    return{
      isReloadBox:true
    }
  },
  components: {

  },
  created() {
    this.$nextTick(() => {
      this.createVideo()
    });
  },
  mounted() {

  },

  methods: {

    createVideo() {
      if (flvjs.isSupported()) {
        var videoElement = document.getElementById('videoElement');
        var flvPlayer = flvjs.createPlayer({
          type: 'flv',
          url: 'ws://192.168.0.117:8080:8080/rtp/0BEBDE51.flv', //你的url地址----ws
          //url:'http://192.168.0.117:8080/rtp/0BEBD2AB.flv' //你的url地址----http
        });
        flvPlayer.attachMediaElement(videoElement);
        flvPlayer.load();
        flvPlayer.play();
      }
    }
  }
}
</script>
